<!DOCTYPE html>
<html>
    <body>
        <h1>Classes</h1>
        <h2>Index</h2>
        <ol>
            <li>
                <a href="#opengl">OpenGL Classes</a>
                <ol>
                    <li><a href="#vertex">Vertex</a></li>
                    <li><a href="#mesh">Mesh</a></li>
                    <li><a href="#shader">Shader</a></li>
                </ol>
            </li>
            <li><a href="">GUI Classes</a></li>
        </ol>
        <h2>Reference</h2>
        <ol>
            <li>
                <h3 id="opengl">OpenGL Classes</h3>
                <ol>
                    <li>
                        <h4 id="vertex">Vertex</h4>
                        <div>
                            <div>Included in "src/OpenGL/vertex.h"</div>
                            <div>As the name suggests, vertex class represents a vertex in 3D space. An instance of this class stores the position and normal vectors.</div>
                            <h5>Properties</h5>
                            <ul>
                                <li>glm::vec3 pos</li>
                                <li>glm::vec3 norm</li>
                            </ul>
                            <h5>Public Functions</h5>
                            <ul>
                                <li>Vertex(glm::vec3 pos = glm::vec3(), glm::vec3 norm = glm::vec3())</li>
                                <li>Vertex(GLfloat x, GLfloat y, GLfloat z, GLfloat nx, GLfloat ny, GLfloat nz)</li>
                                <li>void setPos(glm::vec3 pos)</li>
                                <li>glm::vec3 getPos()</li>
                                <li>void setNorm(glm::vec3 norm)</li>
                                <li>glm::vec3 getNorm()</li>
                            </ul>
                        </div>
                    </li>
                    <li>
                        <h4 id="mesh">Mesh</h4>
                        <div>Included in "src/OpenGL/mesh.h"</div>
                        <div>Mesh class represents a 3D geometry. An instance of this class stores the IDs of Vertex Array Objects(VAO), Vertex Buffer Objects(VBO) and Index Buffer Objects(IBO). The data of these objects is stored in the GPU and is accessible via these IDs. VAOs are containers for VBOs and IBOs and contain the information of how to interpret the the data stored in VBOs and IBOs. VBOs store all the data of vertices. IBOs store the indices of vertices which represent which vertices form the polygons specified. For example if the drawMode enum is set to GL_TRIANGLES, then the 3D object is composed of triangles. First 3 vertices as specified in the IBO represent a triangle, the next 3 represent another triangle and so on.</div>
                        <h5>Properties</h5>
                        <ul>
                            <li>
                                <div>GLsizei numIndices</div>
                                <div>Number of elements in the IBO</div>
                            </li>
                            <li>
                                <div>GLsizei numVertices</div>
                                <div>Number of vertices in the 3D geometry.</div>
                            </li>
                            <li>
                                <div>GLuint VAO</div>
                                <div>ID of VAO</div>
                            </li>
                            <li>
                                <div>GLuint VBO</div>
                                <div>ID of VBO</div>
                            </li>
                            <li>
                                <div>GLuint IBO</div>
                                <div>ID of IBO</div>
                            </li>
                            <li>
                                <div>GLenum usageMode</div>
                                <div>Determines the usage pattern of the data store. Refer to <a href="http://docs.gl/gl3/glBufferData">http://docs.gl/gl3/glBufferData</a> for different usage modes.</div>
                            </li>
                            <li>
                                <div>GLenum drawMode</div>
                                <div>Determines which primitives to render. Refer to <a href="http://docs.gl/gl3/glDrawElements">http://docs.gl/gl3/glDrawElements</a> for the available options.</div>
                            </li>
                        </ul>
                        <h5>Public Functions</h5>
                        <ul>
                            <li>
                                <div>Mesh()</div>
                                <div>Empty Contructor</div>
                            </li>
                            <li>
                                <div>Mesh(std::vector&lt;Vertex&gt;& vertices, std::vector&lt;unsigned int&gt;& indices, GLenum usageMode = GL_STATIC_DRAW, GLenum drawMode = GL_TRIANGLES)</div>
                                <div>Contructs the mesh with the given vector of vertices and indices, usageMode and drawMode. The constructor only calls Mesh::createMesh() function.</div>
                            </li>
                            <li>
                                <div>~Mesh()</div>
                                <div>Destructor of the class. It only calls Mesh::clearMesh() function</div>
                            </li>
                            <li>
                                <div>void createMesh(std::vector&lt;Vertex&gt;& vertices, std::vector&lt;unsigned int&gt;& indices)</div>
                                <div>This function can be used to create the 3D geometry for this mesh(or replace if the mesh already contained another geometry). This function creates the VAO, VBO and IBO and loads the data from the vertices and indices vectors specified into those buffers.</div>
                            </li>
                            <li>
                                <div>void clearMesh()</div>
                                <div>Deletes the VAO, VBO and IBO from the memory if they exist.</div>
                            </li>
                            <li>
                                <div>void renderMesh()</div>
                                <div>Draws the mesh on the screen. Must be called only if Mesh::empty() returns false. Before calling this function, make sure to bind a shader program object before and assign values to the uniform variables linked to the shader. It's better to use the Model class rather than doing this manually.</div>
                            </li>
                            <li>
                                <div>bool empty()</div>
                                <div>Returns the boolean value if an instance of this class contains a mesh or not.</div>
                            </li>
                            <li>void setUsageMode(GLenum usageMode)</li>
                            <li>GLenum getUsageMode()</li>
                            <li>void setDrawMode(GLenum drawMode)</li>
                            <li>GLenum getDrawMode()</li>
                            <li>
                                <div>void updateVertexBuffer(std::vector&lt;Vertex&gt;& vertices, GLintptr offset = 0)</div>
                                <div>Updates the data of VBO from offset index to offset + vertices.size() - 1 index both inclusive. Therefore offset + vertices.size() must be less than or equal to numVertices. Call this function only if the buffers are dynamic.</div>
                            </li>
                            <li>
                                <div>void updateIndexBuffer(std::vector&lt;unsigned int&gt;& indices, GLintptr offset = 0)</div>
                                <div>Updates the data of IBO from offset index to offset + indices.size() -1 index both inclusive. Therefore offset + indices.size() must be less than or equal to numIndices. Call this function only if the buffers are dynamic.</div>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <h4 id="shader">Shader</h4>
                        <div>Included in "src/OpenGL/shader.h"</div>
                        <div>Shader class provides a mechanism of loading codes for vertex and fragment shaders which are programmable steps of the rendering pipeline in OpenGL. In order to use this mechanism, use the void Shader::loadShader(std::string& vPath, std::string& fPath) function. By default this class only allows support for 3 uniform variables: model matrix, view matrix and projection matrix. It is necessary to set the values of these uniform variables. To have more uniform variables, subclass Shader class and then override void Shader::setupUniforms and void Shader::clearUniforms virtual functions.</div>
                        <h5>Private Properties</h5>
                        <ul>
                            <li>
                                <div>GLuint program</div>
                                <div>ID of the program object. In OpenGL, in order to use shaders, we are supposed to create a program object and then link shaders to this program object and then bind this program object. Also, unforms variables are setup through the program object as well.</div>
                            </li>
                            <li>
                                <div>GLuint uniformModel</div>
                                <div>The location of model matrix uniform.</div>
                            </li>
                            <li>
                                <div>GLuint uniformProjection</div>
                                <div>The location of projection matrix uniform.</div>
                            </li>
                            <li>
                                <div>uniformView</div>
                                <div>The location of view matrix uniform.</div>
                            </li>
                        </ul>
                        <h5>Private Functions</h5>
                        <ul>
                            <li>
                                <div>void addShader(std::string& shaderCode, GLenum shaderType)</div>
                                <div>This function creates a shader of type shaderType with the code shaderCode and then links it to the program object.</div>
                            </li>
                            <li>
                                <div>std::string readFile(std::string& path)</div>
                                <div>This functions returns the content of the file at path.</div>
                            </li>
                        </ul>
                        <h5>Protected Functions</h5>
                        <ul>
                            <li>virtual void setupUniforms()</li>
                            <li>virtual void clearUniforms()</li>
                        </ul>
                        <h5>Public Functions</h5>
                        <ul>
                            <li>Shader()</li>
                            <li>virtual ~Shader()</li>
                            <li>void loadShader(std::string& vPath, std::string fPath)</li>
                            <li>void clearShader</li>
                            <li>GLuint getShaderId()</li>
                            <li>Gluint getModelLocation()</li>
                            <li>GLuint getProjectionLocation()</li>
                            <li>GLuint getViewLocation()</li>
                            <li>bool empty()</li>
                            <li>void useShader()</li>
                        </ul>
                        <h5>Public Static Functions</h5>
                        <ul>
                            <li>void unUseShader()</li>
                        </ul>
                    </li>
                </ol>
            </li>
        </ol>
    </body>
</html>